//
//  FKRefundAmountCell.m
//  WanTao
//
//  Created by Macbook Pro on 2019/4/3.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKRefundAmountCell.h"

@interface FKRefundAmountCell ()

@property (nonatomic, weak) UILabel *backAmountLabel;
@property (nonatomic, weak) UILabel *backBalanceLabel;

@end

@implementation FKRefundAmountCell

- (void)setupSubviews
{
    [super setupSubviews];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UILabel *backAmountTitle = [UILabel fk_labelWithFont:fk_adjustFont(14) textColor:fkColor333333];
    [self.contentView addSubview:backAmountTitle];
    
    UILabel *backAmountLabel = [UILabel fk_labelWithFont:fk_adjustFont(14) textColor:fkMainColor];
    [self.contentView addSubview:backAmountLabel];
    self.backAmountLabel = backAmountLabel;
    
    UIView *separator = [[UIView alloc] init];
    [self.contentView addSubview:separator];
    separator.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    UILabel *backBalanceTitle = [UILabel fk_labelWithFont:fk_adjustFont(14) textColor:fkColor333333];
    [self.contentView addSubview:backBalanceTitle];
    
    UILabel *backBalanceLabel = [UILabel fk_labelWithFont:fk_adjustFont(14) textColor:fkColor333333];
    [self.contentView addSubview:backBalanceLabel];
    self.backBalanceLabel = backBalanceLabel;
    
    [separator mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.right.offset(-12);
        make.height.offset(0.8);
        make.centerY.offset(0);
    }];
    [backAmountTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(separator);
        make.top.offset(0);
        make.bottom.equalTo(separator.mas_top);
    }];
    [backAmountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(separator);
        make.centerY.equalTo(backAmountTitle);
    }];
    [backBalanceTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(separator);
        make.top.equalTo(separator.mas_bottom);
        make.bottom.offset(0);
    }];
    [backBalanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(separator);
        make.centerY.equalTo(backBalanceTitle);
    }];
}

- (void)setData:(id)data
{
    [super setData:data];
    
    if ([data isKindOfClass:[NSDictionary class]]) {
        self.backAmountLabel.text = fkFORMAT(@"￥ %@", data[@"refund_price"]);
        self.backBalanceLabel.text = fkFORMAT(@"￥ %@", data[@"real_price"]);
    }
}

@end
